class Spreadsheet {
public:
    Spreadsheet(int rows) {
        _net.resize(rows);
        for (int i = 0; i < rows; i++)
            _net[i].resize(26, 0);
    }

    void setCell(string cell, int value) {
        int hang = stoi(cell.substr(1)) - 1;
        _net[hang][cell[0] - 'A'] = value;
    }

    void resetCell(string cell) {
        int hang = stoi(cell.substr(1)) - 1;
        _net[hang][cell[0] - 'A'] = 0;
    }

    int getValue(string formula) {
        string s1, s2;
        int n1, n2;
        for (int i = 0; i < formula.size(); i++) {
            if (formula[i] == '+') {
                s1 = formula.substr(1, i - 1);
                s2 = formula.substr(i + 1);
                break;
            }
        }
        if (s1[0] >= 'A' && s1[0] <= 'Z') {
            int hang = stoi(s1.substr(1)) - 1;
            n1 = _net[hang][s1[0] - 'A'];
        }
        else
            n1 = stoi(s1);
        if (s2[0] >= 'A' && s2[0] <= 'Z') {
            int hang = stoi(s2.substr(1)) - 1;
            n2 = _net[hang][s2[0] - 'A'];
        }
        else
            n2 = stoi(s2);

        return n1 + n2;
    }
private:
    vector<vector<int>> _net;
};

/**
 * Your Spreadsheet object will be instantiated and called as such:
 * Spreadsheet* obj = new Spreadsheet(rows);
 * obj->setCell(cell,value);
 * obj->resetCell(cell);
 * int param_3 = obj->getValue(formula);
 */